package com.bawei.module_login.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.bawei.module_base.net.bean.login.FindLabelsBean
import com.bawei.module_base.net.util.HttpUtils
import com.bawei.module_base.ui.base.BaseResult
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch


class LabelViewModel:ViewModel() {

    /**
     *网络获取的方法
     */
    val dataLabel= MutableLiveData<BaseResult<List<FindLabelsBean>>>()
    fun getRequestLabel() {
        viewModelScope.launch (Dispatchers.IO){

                var result= HttpUtils.apiService.getFindLabels()
                dataLabel.postValue(result)

        }

    }
    /**
     * 添加标签
     */
    val dataSaveTag= MutableLiveData<BaseResult<String?>>()
    fun postSaveTag(map:HashMap<String,String>){
//        val joinToString = map.keys.joinToString()
        viewModelScope.launch (Dispatchers.IO){
            var result= HttpUtils.apiService.postSaveTag("aaa")
            dataSaveTag.postValue(result)
        }
    }
}